package com.tapstitch.scm.common.core.repository;




import com.tapstitch.scm.common.core.repository.condition.BaseCondition;
import com.tapstitch.scm.common.core.repository.condition.PageIterator;

import java.util.List;


public interface IBaseRepository<T> {

    /**
     * 默认分页时的第一个参数
     */
    int PAGE_NO = 1;

    /**
     * 分页
     *
     * @param condition conditions
     * @param pageNo    PAGE_NO
     * @param pageSize  pageSize
     * @return PageIterator<T>
     */
    PageIterator<T> flip(BaseCondition condition, int pageNo, int pageSize, boolean count);

    /**
     * by Id
     *
     * @param id id
     * @return T
     */
    T getById(Long id);

    /**
     * save
     *
     * @param model model
     * @return Boolean
     */
    Boolean save(T model);

    /**
     * batch save
     *
     * @param list list
     */
    void save(List<T> list);

    /**
     * update by Id
     *
     * @param model model
     * @return Boolean
     */
    Boolean updateById(T model);

    /**
     * batch update
     *
     * @param list list
     */
    void updateById(List<T> list);

}
